package com.qiwx.pigeon.adapter.produce;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qiwx.pigeon.R;
import com.qiwx.pigeon.data.CageStatusConfig;
import com.qiwx.pigeon.data.vo.CageBean;
import com.qiwx.pigeon.data.vo.FertilizeBean;
import com.qiwx.pigeon.widget.EggView;

import java.util.List;

/**
 * @description
 * @Author qiwx
 * @Date 2020-03-31 14:16
 * 查蛋
 **/
public class CheckEggAdapter extends BaseQuickAdapter<FertilizeBean, BaseViewHolder> {
    public CheckEggAdapter(int layoutResId, List<FertilizeBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, FertilizeBean cageBean) {
        holder.setText(R.id.txt_number, cageBean.getC_number() + "号");
        EggView eggView = holder.getView(R.id.img_status);
//
        if (cageBean.isSelected()) {
            holder.setBackgroundResource(R.id.lin_root, R.drawable.rb_bg_blue);
        } else {
            holder.setBackgroundResource(R.id.lin_root, R.drawable.rb_bg_gray);
        }
        int eggStatus = cageBean.getEgg_status();
        int produceStatus = cageBean.getProduce_status();
        int amount = cageBean.getAmount();
        if (produceStatus == CageStatusConfig.PRODUCE_CK) {
//            eggView.setText(cageBean.getAmount() + "");
//            eggView.setEggColor(getContext().getResources().getColor(R.color.egg_ck_color));
        } else if (produceStatus == CageStatusConfig.PRODUCE_FD
                || produceStatus == CageStatusConfig.PRODUCE_CZ
                || produceStatus == CageStatusConfig.PRODUCE_CZ2) {

//            eggView.setText(CageStatusConfig.getAmountByEggStatus(eggStatus) + "");
//            int colorId = CageStatusConfig.getColorByEggStatus(eggStatus);
//            eggView.setEggColor(getContext().getResources().getColor(colorId));
        } else if (produceStatus == CageStatusConfig.PRODUCE_YD) {
//            eggView.setText(cageBean.getAmount() + "");
//            eggView.setEggColor(getContext().getResources().getColor(R.color.green_light));
        } else if (produceStatus == CageStatusConfig.PRODUCE_KW) {
//            amount = 0;
//            eggView.setText("");
//            eggView.setEggColor(getContext().getResources().getColor(R.color.green_light));
        }
        if(produceStatus==CageStatusConfig.PRODUCE_KW){
            eggView.setText("");
        }else {
            eggView.setText(amount + "");
        }

        //空窝，有蛋 查蛋什么都不做


    }
}
